﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
using COM.Rights.Model;
using COM.Rights.BLL;
using System.Data;
using COM.PreAlarm.BLL;
using COM.PreAlarm.Model;

public partial class FrontPages_UserControl_NewsList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            InitNewsList();
            
        }
    }

    public string StyleName{
        get{
            return CssControler.GetCssFileNameByHost(HostName);
        }
    } 

    protected void aspNetPage_PageChanged(object sender, EventArgs e)
    {
        this.InitNewsList();
    }

    private string _HostName;
    public string HostName
    {
        get
        {
            if (StringHelper.FormatObjToString(ViewState["HostName"]) != string.Empty) {
                return StringHelper.FormatObjToString(ViewState["HostName"]);
            }
            else if (!string.IsNullOrEmpty(hidHostName.Value))
            { ViewState["HostName"] = hidHostName.Value; return hidHostName.Value; }

            return this._HostName;
        }
        set
        {
            ViewState["HostName"] = value;
        }
    }


    protected void InitNewsList() {
        //HostName = "www.ilenor.cc";
        BdNews _BdNews = new BdNews();
        List<System.DBParameter> _listDBParameter = new List<System.DBParameter>();
        int? i = 0;
        DataTable dt = _BdNews.GetDataTable(this.aspNetPage.CurrentPageIndex, this.aspNetPage.PageSize, ref i, "News_ID,NewsTitle,CONVERT(VARCHAR(10),PublishDate,120) PublishDate", string.Format(" HostName LIKE '%{0}%' AND IsDelete = 0  AND  IsPublish = 1", HostName), "PublishDate DESC, News_ID", _listDBParameter);
        this.aspNetPage.RecordCount = (int)i;
        this.aspNetPage.DataBind();
        this.repNewsTop10.DataSource = dt;
        this.repNewsTop10.DataBind();

       


    }

}